package com.yyx.jupiter.controller;

import com.yyx.jupiter.entity.RecomReq;
import com.yyx.jupiter.entity.RecomResp;
import com.yyx.jupiter.entity.RecomVideo;
import com.yyx.jupiter.service.ablation.AblationService;
import jakarta.annotation.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.yyx.jupiter.service.recommend.HomeRecommendService;

@RestController
@Validated
@RequestMapping("/recommend")
public class RecommendController {

    @Resource
    AblationService ablationService;

    @Resource
    HomeRecommendService homeRecommendService;

    @PostMapping(value = "/home_recommend")
    public RecomResp<RecomVideo> homeRecommend(@RequestBody RecomReq recomReq) throws Exception {
        String strategy = ablationService.getStrategy("home_abtest", recomReq.getUserId());
        recomReq.setStrategy(strategy);
        return homeRecommendService.recommend(recomReq);
    }
}
